#include<iostream>
using namespace std;
const int N = 1e6 + 10;
int primes[N], cnt;
typedef pair<int, int> PII;
PII p[N];
bool st[N];
void get_prime(int l, int r)
{
	for (int i = l; i <= r; i++) {
		if (!st[i])primes[++cnt] = i;
		for (int j = 1; primes[j] <= r / i; j++) {
			st[primes[j] * i] = 1;
			if (i % primes[j] == 0)break;
		}
	}
}
int main()
{
	get_prime(2, 1e5);
	get_prime(1e5 + 1, 2e10 - 1);
	int ans1 = 1e9;
	int ans2 = -1e9;
	int m = 0;
	for (int i = 1; i <= cnt; i++) {
		if (i + 1 <= cnt) {
			if (primes[i + 1] - primes[i] < ans1) {
				ans1 = primes[i + 1] - primes[i];
				p[++m] = { primes[i],primes[i + 1] };
			}
			if (primes[i + 1] - primes[i] > ans2) {
				ans2 = primes[i + 1] - primes[i];
				p[++m] = { primes[i],primes[i + 1] };
			}
		}
	}
	if (ans1 == 1e9 || ans2 == -1e9) {
		cout << "There are no adjacent primes." << endl;
	}
	else {
		cout << ans1 << " " << ans2 << endl;
	}
	return 0;
}